//
//  XHContactUsViewController.m
//  umibus
//
//  Created by 冷山 on 16/6/18.
//  Copyright © 2016年 lexingsoft. All rights reserved.
//

#import "XHContactUsViewController.h"
#import "XHMakePhoneCallViewController.h"

#import "XHSettingCell.h"

#import <UIAlertView+Blocks.h>

@interface XHContactUsViewController ()
@property (weak, nonatomic) IBOutlet UITableView *ui_tableView;

@end

@implementation XHContactUsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.ui_tableView registerNib:[UINib nibWithNibName:@"XHSettingCell" bundle:nil] forCellReuseIdentifier:XHSettingCellIdentifier];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    int rows=3;
    return rows;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = nil;
    cell=[self configOtherCellWithIndexPath:indexPath];
    return cell;
}


-(XHSettingCell *)configOtherCellWithIndexPath:(NSIndexPath *)indexPath
{
    XHSettingCell *cell = [self.ui_tableView dequeueReusableCellWithIdentifier:XHSettingCellIdentifier];
    cell.ui_detailLabel.hidden=YES;
    cell.ui_switch.hidden=YES;
    if (indexPath.row==0)
    {
        cell.ui_titleLabel.text=@"官方网站";
        cell.ui_line.hidden = NO;
        cell.ui_jianTou.hidden = NO;
    }
    else if (indexPath.row==1)
    {
        cell.ui_titleLabel.text=@"官方微博";
        cell.ui_line.hidden = NO;
        cell.ui_jianTou.hidden = NO;
    }
    else if (indexPath.row==2)
    {
        cell.ui_titleLabel.text=@"官方电话";
        cell.ui_line.hidden = NO;
        cell.ui_jianTou.hidden = YES;
    }
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (indexPath.row==0)
    {
        //官方网站
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.umibus.com"]];
    }
    else if (indexPath.row==1)
    {
        //官方微博
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://weibo.com/umibus"]];
    }
    else if (indexPath.row==2)
    {
        //官方电话
        XHMakePhoneCallViewController * viewController = [[XHMakePhoneCallViewController alloc]init];
        viewController.modalPresentationStyle = UIModalPresentationCustom;
        [self presentViewController:viewController animated:NO completion:^{
            
        }];
    }
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    CGFloat height=55;
    return height;
}

- (CGFloat)tableView:(UITableView*)tableView heightForHeaderInSection:(NSInteger)section
{
    CGFloat height = 0.1;
    return height;
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
